﻿<%@ Page Title="" Language="C#" MasterPageFile="~/OneColumn.Master" AutoEventWireup="true" CodeBehind="Company.aspx.cs" Inherits="KCL.Organization.Company1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PageTitle" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PageHeader" runat="server">
    <link type="text/css" href="../styles/themes/base/jquery.ui.all.css" rel="stylesheet" />
	<link type="text/css" href="../styles/css/uploadify.css" rel="stylesheet" />
    <script type="text/javascript" src="../styles/ui/jquery.ui.core.js"></script>
    <script type="text/javascript" src="../styles/ui/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="../styles/ui/jquery.ui.position.js"></script>
    <script type="text/javascript" src="../styles/ui/jquery.ui.mouse.js"></script>
    <script type="text/javascript" src="../styles/ui/jquery.ui.draggable.js"></script>
    <script type="text/javascript" src="../styles/ui/jquery.ui.dialog.js"></script>
    <script type="text/javascript" src="../styles/ui/jquery.ui.button.js"></script>
    <script type="text/javascript" src="../styles/external/jquery.bgiframe-2.1.2.js"></script>
	<script type="text/javascript" src="../styles/js/swfobject.js"></script>
	<script type="text/javascript" src="../styles/js/jquery.uploadify.js"></script>
    <script type="text/javascript">
    	$(document).ready(function () {
    		$("#divCreateCompany").dialog({
    			autoOpen: false,
    			modal: true,
    			width: 830,
    			height: 450,
    			maxHeight: 800,
    			title: 'Chỉnh sửa thông tin công ty',
    			resizable: true
    		});
    		$("#btnSave").button();
    		$("#inputLogo").uploadify({
    			'uploader': '../styles/js/uploadify.swf',
    			'script': 'company.ashx', 'cancelImg': '../styles/images/cancel.png',
    			'auto': false,
    			'buttonText': 'Select logo',
    			'fileExt': '*.jpg;*.gif;*.png',
    			'fileDesc': 'Web Image Files (.JPG, .GIF, .PNG)',
    			'removeCompleted': false,
    			'onComplete': function (event, ID, fileObj, response, data) { alert('Chỉnh sửa thành công.'); location.reload(true); }
    		});
    	});
    	function UpdateCompany() {
    		if ($('#inputLogoQueue').children().length > 0) {
    			$('#inputLogo').uploadifySettings('scriptData', { companyName: $("#companyName").val(), address: $("#address").val(), phone: $("#phone").val(), mobile: $("#mobile").val(), fax: $("#fax").val(), accountNumber: $("#accountNumber").val(), bank: $("#bank").val(), taxNumber: $("#taxNumber").val(), director: $("#director").val() }, false);
    			$('#inputLogo').uploadifyUpload();
    		}
    		else $.ajax({
    			url: "Company.ashx?",
    			type: "POST",
    			dataType: "script",
    			data: {
    				companyName: $("#companyName").val(),
    				address: $("#address").val(),
    				director: $("#director").val(),
    				phone: $("#phone").val(),
    				mobile: $("#mobile").val(),
    				fax: $("#fax").val(),
    				accountNumber: $("#accountNumber").val(),
    				bank: $("#bank").val(),
    				taxNumber: $("#taxNumber").val()
    			}
    		});
        }
        function EditCompany() {
            $("#companyName").val('<%= myCompany.name %>');
            $("#address").val('<%= myCompany.address %>');
            $("#director").val('<%= myCompany.director %>');
            $("#phone").val('<%= myCompany.phone %>');
            $("#mobile").val('<%= myCompany.mobile %>');
            $("#fax").val('<%= myCompany.fax %>');
            $("#accountNumber").val('<%= myCompany.accountNumber %>');
            $("#bank").val('<%= myCompany.bank %>');
            $("#taxNumber").val('<%= myCompany.taxNumber %>');
            $("#divCreateCompany").dialog("open");
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
	<div style="background-image: '../styles/images/center.jpg'"><h2>THÔNG TIN CÔNG TY</h2></div>
	Tên công ty: <%= myCompany.name %><br /><br />
	Địa chỉ: <%= myCompany.address %><br /><br />
	Giám đốc: <%= myCompany.director %><br /><br />
	Số đt cố định: <%= myCompany.phone %>
	<span style="float:none; margin-left:90px">Mobile: <%= myCompany.mobile %></span>
	<span style="float:none; margin-left:90px">Fax: <%= myCompany.fax %></span><br /><br />
	Số tài khoản: <%= myCompany.accountNumber %>
	<span style="float:none; margin-left:90px">Ngân hàng: <%= myCompany.bank %></span><br /><br />
	Mã số thuế: <%= myCompany.taxNumber %><p />
    <input type="button" id="btnEditCompany" value="Sửa thông tin công ty" onclick="EditCompany()" />
    <div id="divCreateCompany">
        <table border="0" cellpadding="7px" cellspacing="3px">
            <tr>
                <td>
                    Tên công ty
                </td>
                <td colspan="6">
                    <input type="text" id="companyName" style="width: 100%" />
                </td>
            </tr>
            <tr>
                <td>
                    Địa chỉ
                </td>
                <td colspan="6">
                    <input type="text" id="address" style="width: 100%" />
                </td>
            </tr>
            <tr>
                <td>
                    Giám đốc
                </td>
                <td colspan="2">
                    <input type="text" id="director" style="width: 100%" />
                </td>
            </tr>
            <tr>
                <td>
                    Số đt cố định
                </td>
                <td>
                    <input type="text" id="phone" />
                </td>
                <td>
                    Mobile
                </td>
                <td>
                    <input type="text" id="mobile" />
                </td>
                <td>
                    Fax
                </td>
                <td>
                    <input type="text" id="fax" />
                </td>
            </tr>
            <tr>
                <td>
                    Số tài khoản
                </td>
                <td>
                    <input type="text" id="accountNumber" />
                </td>
                <td>
                    Ngân&nbsp;hàng
                </td>
                <td colspan="3">
                    <input style="width: 100%" type="text" id="bank" />
                </td>
            </tr>
            <tr>
                <td>
                    Mã số thuế
                </td>
                <td colspan="2">
                    <input type="text" id="taxNumber" style="width: 100%" />
                </td>
            </tr>
            <tr>
                <td>
                    Logo
                </td>
                <td colspan="3">
                    <input type="file" id="inputLogo" />
                </td>
            </tr>
        </table>
        <p />
        <center>
            <input type="button" id="btnSave" value="&nbsp;Lưu&nbsp;" onclick="UpdateCompany();" /></center>
    </div>
</asp:Content>